<template>
	<view class="">
		<view class="uni-form-item uni-column">
			<view class="title">姓名</view>
			<input class="uni-input" v-model="FormData.name" disabled />
		</view>
		<view class="uni-form-item uni-column">
			<view class="title">存款金额/元</view>
			<input class="uni-input" v-model="FormData.money" focus placeholder="请输入存款金额/元" />
		</view>
		<view class="uni-form-item uni-column">
			<view class="title">存款期限/月</view>
			<input class="uni-input" v-model="FormData.time" placeholder="请输入存款期限" />
		</view>
		<view class="uni-padding-wrap uni-common-mt">
			<button type="primary" @click="add">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				FormData: {
					name: '',
					money: '',
					time: '',
					id: ''
				}
			}
		},
		onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数
				console.log(option.name); //打印出上个页面传递的参数。
				this.FormData.name = option.name || '无信息'
				this.FormData.id = option.id
		},
		methods: {
			add() {
				let params = {
					khId: this.FormData.id,
					money: this.FormData.money,
					month: this.FormData.time,
				}
				this.$api.setCkfq(params).then((res) => {
					if(res.success) {
					uni.showToast({
						icon: 'success',
						title: "成功",
						duration: 2000,
					})
					setTimeout(() => {
						uni.navigateBack({
						    url: 'deposit'
						});
					}, 500)
					}else {
						uni.showToast({
							icon: 'none',
							title: res.msg,
							duration: 2000
						});
					}
				}).catch((err) => {
					console.log('request fail', err);
				})
			}
		}
	}
</script>

<style>
	
</style>
